import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BrandVO, BrandForm, BrandQuery } from '@/api/goods/brand/types';

/**
 * 查询品牌列表
 * @param query
 * @returns {*}
 */

export const listBrand = (query?: BrandQuery): AxiosPromise<BrandVO[]> => {
  return request({
    url: '/order/goodsBrand/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询品牌详细
 * @param id
 */
export const getBrand = (id: string | number): AxiosPromise<BrandVO> => {
  return request({
    url: '/order/goodsBrand/' + id,
    method: 'get'
  });
};

/**
 * 查询品牌详细
 */
export const getBrandAllList = (): AxiosPromise<BrandVO> => {
  return request({
    url: '/order/goodsBrand/allList',
    method: 'get'
  });
};

// 查询所有品牌
export const getBrandSort = (): AxiosPromise<BrandVO> => {
  return request({
    url: '/order/goodsBrand/getBrandSort',
    method: 'get'
  })
}
/**
 * 新增品牌
 * @param data
 */
export const addBrand = (data: BrandForm) => {
  return request({
    url: '/order/goodsBrand',
    method: 'post',
    data: data
  });
};

/**
 * 修改品牌
 * @param data
 */
export const updateBrand = (data: BrandForm) => {
  return request({
    url: '/order/goodsBrand',
    method: 'put',
    data: data
  });
};

/**
 * 删除品牌
 * @param id
 */
export const delBrand = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/goodsBrand/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param goodsBrandId 客户端id
 * @param status 状态
 */
export function changeStatus(goodsBrandId: string, status: string) {
  const data = {
    goodsBrandId,
    status
  };
  return request({
    url: '/order/goodsBrand/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list: listBrand,
  get: getBrand,
  add: addBrand,
  update: updateBrand,
  del: delBrand,
  getBrandAllList: getBrandAllList,
  getBrandSort: getBrandSort,
}